// pages/liwu/liwu.js
// var data = require("../../js/zhaopian")
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    liwu: [
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYaIz1KZoaPU.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYk6np6dKdWA.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYqMUZOLyutc.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHe40XFqmTQp8.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYQyAOhxZwT4.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYohyLM6CPbu.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYOzQbRsz9vG.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHY2fUazwkn2Q.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYeXeDP5v2Az.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYBlu48J1e34.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYDIwUpI1RMZ.jpg'
    ],
    imgs:[
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYaIz1KZoaPU.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYk6np6dKdWA.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYqMUZOLyutc.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHe40XFqmTQp8.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYQyAOhxZwT4.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYohyLM6CPbu.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYOzQbRsz9vG.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHY2fUazwkn2Q.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYeXeDP5v2Az.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYBlu48J1e34.jpg',
      'https://cloud-minapp-45172.cloud.ifanrusercontent.com/1orKHYDIwUpI1RMZ.jpg'
    ]
  },

   //预览图片，放大预览
   preview(event) {
    console.log(event.currentTarget.id)
    let currentUrl = event.currentTarget.id
    wx.previewImage({
      current: currentUrl, // 当前显示图片的http链接
      urls:this.data.imgs // 需要预览的图片http链接列表
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var liwu = this.data.liwu

    var items = []
    for(var i = 0 ; i < liwu.length; i++){
      var a = Math.floor(Math.random()*5)
      var c = Math.floor(Math.random()*5)
      var b = Math.floor(Math.random()*4)
      var item = {
        img :liwu[i],
        bg : app.globalData.color[a],
        tab:app.globalData.tab[b],
        bgc:app.globalData.color[c],
        tab2:app.globalData.tab[b]
      }
      items.push(item)
    }
    this.setData({
      liwu:items
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})